﻿CREATE TABLE [dbo].[DinnerBill] (
    [Id]                   INT             IDENTITY (1, 1) NOT NULL,
    [OpenId]               NVARCHAR (50)   NOT NULL,
    [BillNo]               NVARCHAR (50)   NOT NULL,
    [BillStatus]           INT             NOT NULL,
    [TotalMoney]           DECIMAL (18, 2) NOT NULL,
    [TotalRefundMoney]     DECIMAL (18, 2) NULL,
    [CreateTime]           DATETIME        NULL,
    [PayTime]              DATETIME        NULL,
    [WxTransactionId]      NVARCHAR (50)   NULL,
    [NextCheckTime]        DATETIME        NULL,
    [BillStatusOnSetCheck] INT             NULL,
    [CheckReserved]        NVARCHAR (50)   NULL,
    [DeleteStatus]         INT             NULL,
    [WxRefundId]           NVARCHAR (50)   NULL,
    PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'主键，自增长', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'Id';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信用户OpenId', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'OpenId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'账单号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'BillNo';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'状态，1支付中2支付失败3支付成功4退款中5退款成功6退款失败', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'BillStatus';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'总金额', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'TotalMoney';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'总已退金额', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'TotalRefundMoney';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'建立时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'CreateTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'支付成功时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'PayTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'微信支付交易号，支付成功后微信返回', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'WxTransactionId';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'系统下次检查时间', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'NextCheckTime';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'(设置系统下次检查时间时)的订单状态', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'BillStatusOnSetCheck';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'系统检查预留字段', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'CheckReserved';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'0-正常 1-删除', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'DeleteStatus';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'收到支付信息时，订单已经关闭时，DinnerBill退款', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'DinnerBill', @level2type = N'COLUMN', @level2name = N'WxRefundId';

